package com.zhss.dfs.namenode.server;

import com.sun.org.apache.xpath.internal.operations.Bool;

/**
 * nameNode的rpc服务接口
 */
public class NameNodeRpcServer {
    private FSNamesystem namesystem;
    private DataNodeManager dataNodeManager;
    public NameNodeRpcServer(FSNamesystem namesystem,DataNodeManager dataNodeManager){
        this.namesystem = namesystem;
        this.dataNodeManager = dataNodeManager;
    }
    /**
     * 创建目录
     * @param path
     * @return
     * @throws Exception
     */
    public boolean mkdir(String path) throws Exception{
        return namesystem.mkdir(path);
    }

    /**
     * dataNode进行注册
     * @param ip
     * @param hostname
     * @return
     * @throws Exception
     */
    public Boolean register(String ip,String hostname) throws Exception{
        return dataNodeManager.register(ip,hostname);
    }
    /**
     * dataNode进行心跳
     * @param ip
     * @param hostname
     * @return
     * @throws Exception
     */
    public Boolean heartbeat(String ip,String hostname) throws Exception{
        return dataNodeManager.heartbeat(ip,hostname);
    }

    public void start(){
        System.out.println("开始监听指定的rpc server的端口号，来接收这个请求");
    }
}
